//
//  ECOrderChekPendingListTableViewCell.m
//  ECERP.CRM
//
//  Created by 刘思麟 on 2018/10/28.
//  Copyright © 2018年 Mac. All rights reserved.
//

#import "ECOrderChekPendingListTableViewCell.h"

@interface ECOrderChekPendingListTableViewCell()

@property (nonatomic,strong) CAShapeLayer * bottomLine;

@end

@implementation ECOrderChekPendingListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)prepareForReuse {
    [super prepareForReuse];
    self.codeLB.text = nil;
    self.sumLB.text = nil;
    self.userLB.text = nil;
    self.nameLB.text = nil;
    self.dateLB.text = nil;
    self.iconImgV.image = nil;
    self.sumChildLB.text = nil;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    if (!self.bottomLine) {
        self.bottomLine = [CAShapeLayer layer];
        self.bottomLine.borderWidth = 0.25 * PX_RELATIVE375;
        self.bottomLine.borderColor = ECCOLOR(0xf2f2f2).CGColor;
        [self.contentView.layer addSublayer:self.bottomLine];
    }
    self.bottomLine.frame = CGRectMake(12 * PX_RELATIVE375, self.contentView.height-0.5*PX_RELATIVE375, self.contentView.width - 24 * PX_RELATIVE375, 0.5 * PX_RELATIVE375);
}

- (void)setupUI {
    __weak typeof(self) weakSelf = self;
    self.dateLB = [UILabel new];
    self.dateLB.font = ECFONT(14 * PX_RELATIVE375);
    //    self.stateLB.textAlignment = NSTextAlignmentRight;
    self.dateLB.textColor = ECCOLOR(0x999999);
    [self.contentView addSubview:self.dateLB];
    [self.dateLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(weakSelf.contentView).mas_offset(15 * PX_RELATIVE375);
        //        make.width.mas_equalTo(32 * PX_RELATIVE375);
        make.right.mas_equalTo(weakSelf.contentView).mas_offset(-12 * PX_RELATIVE375);
    }];
    
    self.codeLB = [UILabel new];
    self.codeLB.font = ECFONT(16 * PX_RELATIVE375);
    self.codeLB.textColor = ECCOLOR(0x333333);
    [self.contentView addSubview:self.codeLB];
    [self.codeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView).mas_offset(12 * PX_RELATIVE375);
        make.centerY.mas_equalTo(weakSelf.dateLB);
        make.right.mas_lessThanOrEqualTo(weakSelf.dateLB.mas_left).mas_offset(-10 * PX_RELATIVE375);
    }];
    
    self.iconImgV = [UIImageView new];
    [self.contentView addSubview:self.iconImgV];
    [self.iconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.contentView).mas_offset(1 * PX_RELATIVE375);
        make.right.mas_equalTo(weakSelf.contentView).mas_offset(-12 * PX_RELATIVE375);
    }];
    
    self.nameLB = [UILabel new];
    self.nameLB.font = ECFONT(12 * PX_RELATIVE375);
    self.nameLB.textColor = ECCOLOR(0x333333);
    [self.contentView addSubview:self.nameLB];
    [self.nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView).mas_offset(12 * PX_RELATIVE375);
        make.centerY.mas_equalTo(weakSelf.contentView).mas_offset(1 * PX_RELATIVE375);
        make.right.mas_lessThanOrEqualTo(weakSelf.iconImgV.mas_left).mas_offset(-10 * PX_RELATIVE375);
    }];
    
    self.sumChildLB = [UILabel new];
    self.sumChildLB.font = ECFONT(12 * PX_RELATIVE375);
    self.sumChildLB.textColor = ECCOLOR(0xff3333);
    [self.contentView addSubview:self.sumChildLB];
    [self.sumChildLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(weakSelf.contentView).mas_offset(-5 * PX_RELATIVE375);
        make.right.mas_equalTo(weakSelf.contentView).mas_offset(-12 * PX_RELATIVE375);
    }];
    
    WS(weakSumChildLB, self.sumChildLB);
    self.sumLB = [UILabel new];
    self.sumLB.font = ECFONT(12 * PX_RELATIVE375);
    self.sumLB.textColor = ECCOLOR(0xff3333);
    [self.contentView addSubview:self.sumLB];
    [self.sumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(weakSumChildLB.mas_top).mas_offset(- 2 * PX_RELATIVE375);
        make.right.mas_equalTo(weakSelf.contentView).mas_offset(-12 * PX_RELATIVE375);
    }];
    
    self.userLB = [UILabel new];
    self.userLB.font = ECFONT(12 * PX_RELATIVE375);
    self.userLB.textColor = ECCOLOR(0x999999);
    [self.contentView addSubview:self.userLB];
    [self.userLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf.contentView).mas_offset(12 * PX_RELATIVE375);
        make.bottom.mas_equalTo(weakSelf.contentView).mas_offset(-12 * PX_RELATIVE375);
        make.right.mas_lessThanOrEqualTo(weakSelf.sumLB.mas_left).mas_offset(-12 * PX_RELATIVE375);
    }];
    
}

@end
